#!/bin/sh
# ccase_winkin_symtab.sh
# 
# Description:
#   Find and winkin a shared sniff symtab file.
#
# Usage:
#   ccase_winkin_symtab.sh <path_of_shared_symtab> [<parse_options>]
#

DEBUG=1
prg=`basename $0`

sharedSymtab=$1
parseOptions=$2
sharedDir=`dirname $sharedSymtab`
symtab=`basename $sharedSymtab`
CRfile=$symtab".CR"

test $DEBUG && echo  "========================================================="
test $DEBUG && echo  "Start $prg - `date`"
test $DEBUG && echo  "Symtab: $symtab"

# test shared directory

if [ ! -d $sharedDir ]; then
    test $DEBUG && echo  "Shared directory $sharedDir not found"
    test $DEBUG && echo  "End $prg - `date`"
    exit 0;
fi

cd $sharedDir

# test configuration record file

if [ ! -r $CRfile ]; then
    test $DEBUG && echo  "Configuration file $CRfile not found"
    test $DEBUG && echo  "End $prg - `date`"
    exit 0;
fi

if [ -r $symtab ]; then
    currentDOfile=`cleartool ls -short $symtab`
fi
DOfile=`grep "DO=" $CRfile | sed "s/DO=//"`

if [ "$DOfile" != "$currentDOfile" ]; then
    test $DEBUG && echo  "Winking in derived object: $DOfile"
    cleartool winkin $DOfile
fi

test $DEBUG && echo  "End $prg - `date`"
